<template>
	<view class="container">
		<!-- 标题栏 -->


		<!-- 表单区域 -->
		<view class="form">
			<!-- 标题输入 -->
			<view class="form-item">
				<text class="label">标题：</text>
				<input class="input" type="text" placeholder="请输入活动标题" v-model="form.title" />
			</view>

			<!-- 内容输入 -->
			<view class="form-item">
				<text class="label">内容：</text>
				<textarea class="textarea" placeholder="请输入活动内容" v-model="form.content"></textarea>
			</view>

			<!-- 图片/视频上传 -->
			<view class="form-item">
				<text class="label">图片/视频：</text>
				<view class="upload-box" @click="handleUpload">
					<text class="upload-text">+</text>
					<text class="upload-desc">点击选择上传</text>
				</view>
			</view>
		</view>

		<!-- 发布按钮 -->
		<view class="publish-button" @click="handleSubmit">
			发布
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				form: {
					title: "",
					content: "",
					media: [], // 存储上传的图片或视频
				},
			};
		},
		methods: {
			// 处理上传
			handleUpload() {
				uni.chooseImage({
					count: 1, // 一次只允许上传一张
					success: (res) => {
						this.form.media.push(...res.tempFilePaths);
						uni.showToast({
							title: "上传成功",
							icon: "success",
						});
					},
				});
			},
			// 处理发布
			handleSubmit() {
				if (!this.form.title || !this.form.content) {
					uni.showToast({
						title: "请填写完整信息",
						icon: "none",
					});
					return;
				}
				uni.showToast({
					title: "发布成功",
					icon: "success",
				});
				// 可以在此调用接口提交数据
			},
		},
	};
</script>

<style>
	.container {
		display: flex;
		flex-direction: column;
		height: 100vh;
		background-color: #f8f8f8;
	}

	/* 顶部标题栏 */


	/* 表单区域 */
	.form {
		padding: 15px;
		background-color: #ffffff;
		border-radius: 8px;
		margin: 10px;
		box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
	}

	.form-item {
		margin-bottom: 15px;
	}

	.label {
		font-size: 16px;
		color: #333333;
		margin-bottom: 5px;
		display: block;
	}

	.input {
		width: 100%;
		height: 40px;
		border: 1px solid #e5e5e5;
		border-radius: 5px;
		padding: 0 10px;
		font-size: 14px;
	}

	.textarea {
		width: 100%;
		height: 100px;
		border: 1px solid #e5e5e5;
		border-radius: 5px;
		padding: 10px;
		font-size: 14px;
		resize: none;
	}

	/* 上传区域 */
	.upload-box {
		width: 100px;
		height: 100px;
		border: 1px dashed #007aff;
		border-radius: 5px;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		cursor: pointer;
	}

	.upload-text {
		font-size: 30px;
		color: #007aff;
	}

	.upload-desc {
		font-size: 12px;
		color: #999999;
		margin-top: 5px;
	}

	/* 发布按钮 */
	.publish-button {
		margin: 20px;
		background-color: #007aff;
		color: #ffffff;
		text-align: center;
		font-size: 18px;
		padding: 15px;
		border-radius: 5px;
	}
</style>